package com.example.demo.controller;

import com.example.demo.entity.ActivityVo;
import com.example.demo.entity.OrderDto;
import com.example.demo.enums.ActivityTypeEnum;
import com.example.demo.service.BaseActivityService;
import com.example.demo.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author LiYuhang
 * @version 0.1
 * @application 活动测试controller
 */
@RestController
public class TestController {
    /**
     * 注入BaseActivityService子类的service,key为子类service的key
     */
    @Autowired
    private Map<String, BaseActivityService> activityServiceMap;

    @RequestMapping("test")
    public void test(ActivityVo vo){
        //活动类型
        Integer activityType = vo.getType();
        //根据枚举  活动类型 获取相应的serviceImpl
        String servicekey = ActivityTypeEnum.getEnumByType(activityType).getService();
        BaseActivityService service = activityServiceMap.get(servicekey);
        service.addActivity(vo);
        service.upDateActivity(vo);
    }

}
